package com.kehutong.question.admin;

import org.coraframework.authz.HasPermission;
import org.coraframework.inject.Inject;
import org.coraframework.json.JSONObject;
import org.coraframework.mvc.MvcAction;
import org.coraframework.mvc.http.Bean;
import org.coraframework.mvc.http.ReqMapping;
import org.coraframework.mvc.http.result.Result;
import com.kehutong.common.util.Token;
import com.kehutong.question.entity.QuestionCommon;
import com.kehutong.question.service.QuestionCommonService;

/**
 * 管理后台-消息管理
 */
@MvcAction
@ReqMapping("/admin/crm/question/common")
public class QuestionCommonController {

    @Inject
    private QuestionCommonService questionService;

    @HasPermission("crm:question:common:view")
    @ReqMapping("/list")
    public Object list(JSONObject jsonObject) {

        return questionService.list(jsonObject);
    }

    @HasPermission("crm:question:common:add")
    @Bean(newInstance=true, copy=true)
    @ReqMapping("/save")
    public Object save(QuestionCommon question, Token token) {

        question.setReleaseUserId(token.getUuid());
        question.setReleaseUserName(token.getUsername());
        return questionService.save(question);
    }

    @HasPermission("crm:question:common:edit")
    @Bean(copy=true)
    @ReqMapping("/update")
    public Object update(QuestionCommon question) {

        return questionService.update(question);
    }

    @HasPermission("crm:question:common:del")
    @ReqMapping("/delete")
    public Object delete(QuestionCommon question) {

        return questionService.delete(question);
    }

    @ReqMapping("/get")
    public Object get(QuestionCommon question) {

        return Result.success(question);
    }

}
